import 'package:flutter/material.dart';
import 'package:edu_assistant/pages/file_page.dart';
import 'package:edu_assistant/pages/media_page.dart';
import 'package:edu_assistant/pages/filterable_list_page.dart';
import 'package:edu_assistant/pages/upload_file_page.dart';
import 'package:edu_assistant/pages/test_layout.dart';

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int _currentIndex = 0;
  final List<Widget> _pages = <Widget>[FilePage(), InitPage(), InitPage(), InitPage(), InitPage()];
  Widget _getBody() {
    return Scaffold(
        body: IndexedStack(
          index: _currentIndex,
          children: _pages,
        ),
        bottomNavigationBar: Theme(
            data: ThemeData(
                highlightColor: Colors.transparent,
                splashColor: Colors.transparent
            ),
            child: BottomNavigationBar(
              type: BottomNavigationBarType.fixed,
              currentIndex: _currentIndex,
              onTap: (index) {
                if (index == 1) {
                  _pages[index] = UploadFilePage();
                } else if (index == 2) {
                  _pages[index] =  TestPage();
                } else if (index == 3) {
                  _pages[index] = MediaPage();
                } else if (index == 4) {
                  _pages[index] = FilterableListPage();
                }
                setState(() {
                  _currentIndex = index;
                });
              },
              unselectedFontSize: 10, // 未选中字体大小
              selectedFontSize: 10, // 选中字体大小
              unselectedItemColor: Colors.blueGrey,
              backgroundColor: Colors.white,
              showSelectedLabels: true,
              selectedItemColor: Colors.amber[800],
              items: const [
                BottomNavigationBarItem(
                  icon: Icon(Icons.home),
                  label: '文件',
                ),
                BottomNavigationBarItem(
                  icon: Icon(Icons.sd_card),
                  label: '宏宇',
                ),
                BottomNavigationBarItem(
                  icon: Icon(Icons.dashboard),
                  label: '测试布局',
                ),
                BottomNavigationBarItem(
                  icon: Icon(Icons.shopping_cart),
                  label: '媒体',
                ),
                BottomNavigationBarItem(
                  icon: Icon(Icons.person),
                  label: '我的',
                ),
              ],
            )));
  }

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return _getBody();
  }
}
class InitPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Text(""),
    );
  }
}
